loadInitData();
function loadInitData() {
    var token = localStorage.getItem("token");
    console.log("token:"+token);
    $.ajax({
        type: "get",
        url: "/demo/XQing",
        headers: {'token': token},
        success: function (result) {
            var loginCustomer=result.data;
            if(loginCustomer!=null){
                var customerId = loginCustomer.customerId;
                var url = "/demo/order?customerId="+customerId;
                $(".head-user").hide();
                $(".user-menu").html('<li class="text"><a href='+url+'>个人中心</a></li>\n' +
                    '                 <li class="text" id="return"><button style="border: none">退出登录</button></li>');
                $(".user-info").show();
            }else {
                $(".head-user").show();
                $(".user-info").hide();
                $(".buy-btn").attr("href","pages/login.jsp");
            }
            $("#return").click(function (){
                var token = localStorage.removeItem("token");
                window.location.href = "http://localhost:8080/demo/index.jsp";
            })
        }
    })
}


$(".show-dates").click(function(event){
    var element=event.target;//事件作用的目标元素
    console.log(element);
    if (element.className!="date-item active"){
        var navbarArr=$(".show-dates").children();
        for(let i = 0;i<navbarArr.length;i++){
            navbarArr[i].className="date-item";
        }
        element.className="date-item active"
    }
})
/*
$(".buy-btn").click(function (event){
    var element=event.target;//事件作用的目标元素
    console.log("1111111111")
    if (loginCustomer==null ){
        window.location.href = "login.jsp";
    }
    console.log("22222222")
    var token = localStorage.getItem("token");
    // var scheduleId=$(".scheduleId:last").text();
    var scheduleId=$(event.target).next().children().eq(0).text();
    console.log(scheduleId)
    $.ajax({
        type:"get",
        url:"MovieSeat?scheduleId="+scheduleId,
        headers: {'token': token},
        success:function (result){

        }
    })
})
*/

